package com.bdqn.mzc.controller;

import com.bdqn.mzc.mapper.UserMapper;
import com.bdqn.mzc.model.Result;
import com.bdqn.mzc.model.Scenicspot;
import com.bdqn.mzc.service.ShowInfoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/trip")
@Slf4j
public class TripController {
    @Autowired
    private ShowInfoService showInfoService;


    @ApiOperation(" 根据景区名称模糊查询景区信息功能")
    @GetMapping("/linkname")
    public Result<List<Scenicspot>> scenicspotByNameLink(String name){
        log.info(name);
       return Result.wrapSuccessfulResult(showInfoService.tripSlectScenicspotByNameLink(name));
    }



    @ApiOperation(" 根据未知条件筛选景区信息功能" +
            " 前端传值格式:name=scenicspotaddress(字段名称)   value=焦作(具体值)" +
            " 后端接收格式: regionid[0]=字段名称  regionid[1]=具体的值")
    @GetMapping("/byunknown")
    @CrossOrigin
    public Result<PageInfo<Scenicspot>> scenicsPotByUnknown
            (@RequestParam(required = false) String []regionid,
             @RequestParam(required = false) String []scenicspotgrade,
             @RequestParam(required = false) String []scenicspotaddress,
             @RequestParam(required = false) String []scenicspotimgscore,
             @RequestParam(required = false) String []scenicspotordersquantity,
             @RequestParam(required = false) String []scenicspotprice,
             @RequestParam(required = false) String []scenicspotopentime,
             @RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum){
        PageHelper.startPage(pageNum,6);
        List<Scenicspot> scenicspots= showInfoService.tripSelectScenicsPotByUnknown(regionid,
                scenicspotgrade,
                scenicspotaddress,
                scenicspotimgscore,
                scenicspotordersquantity,
                scenicspotprice,
                scenicspotopentime);
        PageInfo<Scenicspot> pageInfo = new PageInfo<Scenicspot>(scenicspots);
        return Result.wrapSuccessfulResult(pageInfo);
    }




}
